package com.daify.threadlearn.chapter01.queue;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * 内部基于链表来存放元素
 * @author daify
 * @date 2019-06-18 13:46
 **/
public class LinkedBlockingQueueTest {
    
    LinkedBlockingQueue queue = new LinkedBlockingQueue();
    
    public void queueTest () throws InterruptedException {
        queue.put(new Object());
        queue.offer(new Object());
        // 设置参数，设置超时时间
        queue.offer(new Object(),5,TimeUnit.SECONDS);

        queue.poll();
        // 取出参数，设置超时时间
        queue.poll(5,TimeUnit.SECONDS);
        // 阻塞的取值
        queue.take();
        
    }
}
